home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-05-26 | 6.4 KB | 225 lines | [TEXT/MPS ] |
- // Copyright ©1994 Apple Computer, Inc.
- // Author: John Powers
- // Date: 05-Mar-94
-
- // UDocMo.h
- // Header for document, art, and related classes.
-
- #ifndef __UDOCMO__
- #define __UDOCMO__ // #endif __UDOCMO__ is at end of this file
-
- // Most of the includes are covered in UApp.h
-
- #include <Windows.h>
- #include <QDOffscreen.h> // GWorld
-
- #ifndef __UAPP__
- #include "UApp.h"
- #endif
-
- // Constants (also see UAppShared.h).
- // ------------------------------------------------------------------------
-
- #define override virtual
-
- // Structures
- // ------------------------------------------------------------------------
-
- typedef struct {
- short pictId;
- short locV;
- short locH;
- short layer;
- short isMoveable;
- short sequenceID;
- char name[32];
- } ArtType, *ArtPtr, **ArtHan;
-
- typedef struct {
- short artCnt;
- ArtType art[1];
- } ArtListType, *ArtListPtr, **ArtListHan;
-
- // ========================================================================
- // TBitMap
- // ------------------------------------------------------------------------
- // The bit map abstract class.
-
- class TBitMap
- {
- private:
- protected:
- Rect fOffRect; // Off-screen rectangle, normalized.
- public:
- TBitMap(void); // constructor
- virtual ~TBitMap(void); // destructor
- virtual void CopyOffToOn(void) {;} // to override
- virtual void CopyOffToOn(Rect& /*rectToCopy*/) {;} // to override
- virtual void CopyOnToOff(void) {;} // to override
- virtual void CopyOnToOff(Rect& /*rectToCopy*/) {;} // to override
- virtual void DoneDrawing(void) {;} // to override
- virtual OSErr Init(void) {return noErr;} // to override
- virtual void PrepareForDrawing(void) {;} // to override
- };
-
- // ========================================================================
- // TBitMapBW-->TBitMap
- // ------------------------------------------------------------------------
- // The bit map B&W class.
-
- class TBitMapBW : public TBitMap
- {
- private:
- GrafPtr fOffPort; // Off-screen grafport.
- GrafPtr fSavedOnPort;
- protected:
- public:
- TBitMapBW(void); // constructor
- virtual ~TBitMapBW(void); // destructor
- virtual void CopyOffToOn(void);
- override void CopyOffToOn(Rect& rectToCopy);
- virtual void CopyOnToOff(void);
- override void CopyOnToOff(Rect& rectToCopy);
- virtual void DoneDrawing(void);
- override OSErr Init(void);
- virtual void PrepareForDrawing(void);
- };
-
- // ========================================================================
- // TBitMapColor-->TBitMap
- // ------------------------------------------------------------------------
- // The bit map color class.
-
- class TBitMapColor : public TBitMap
- {
- private:
- GWorldPtr fOffGWorld; // Off-screen world
- CGrafPtr fSavedOnPort;
- GDHandle fSavedOnDevice;
- protected:
- public:
- TBitMapColor(void); // constructor
- virtual ~TBitMapColor(void); // destructor
- virtual void CopyOffToOn(void);
- override void CopyOffToOn(Rect& rectToCopy);
- virtual void CopyOnToOff(void);
- override void CopyOnToOff(Rect& rectToCopy);
- virtual void DoneDrawing(void);
- override OSErr Init(void);
- virtual void PrepareForDrawing(void);
- };
-
- // ------------------------------------------------------------------------
- // A new art class.
- // The art drawn in the window.
- class TArt
- {
- enum {
- kBWOffset = 1 // B&W ID = ColorID+kBWOffset
- };
- private:
- ArtType fArt;
- short fLastDepth;
- Rect fDrawRect; // Rect of art in window.
- protected:
- public:
- virtual void Draw(short depth);
- virtual void Draw(void);
- virtual void GetDrawRect(Rect* theRect);
- virtual short GetLayer(void) {return this->fArt.layer;}
- virtual void GetName(char* theName);
- virtual short GetSequenceID(void) {return this->fArt.sequenceID;}
- virtual void Init(ArtType theArt);
- virtual Boolean IsMoveable(void) {return this->fArt.isMoveable;}
- virtual void SetDrawRect(Rect* theRect);
- };
-
- // ------------------------------------------------------------------------
- // A class for the art window.
- // Manages everything inside the window.
- class TDocArt : public TDoc
- {
- enum {
- kNotCaseSens = false,
- kNotDiacSens = false
- };
- private:
- short fArtResId; // Art resource id.
- short fArtCnt; // Number of art objects
- Boolean fIsCollision; // True if a collision occurred.
- Boolean fWantReset; // True if a reset is wanted.
- Boolean fWantShuffle; // True if a shuffle is wanted.
- Boolean fWantCollision; // True if collision event wanted.
- AGEvent fCollisionEvent;// Event to send if a collision occurred.
- Handle fhArt; // Handle to art object list.
- TBitMap* fOffScreen; // Our off-screen bitmap.
- static pascal void DrawProc(short depth, short deviceFlags,
- GDHandle hTargetDevice,
- long userData);
- virtual void DragArt(TArt* theArt);
- virtual void DrawOff(TArt* exceptArt);
- virtual Boolean IsCollision(TArt* theArt, Rect* proposedArtRect);
- virtual Boolean IsOutsideWindow(Rect* proposedArtRect);
- virtual Boolean IsSameLayer(TArt* theArt, TArt* theOtherArt);
- protected:
- public:
- // Constructor and destructor
- TDocArt(short resID);
- virtual ~TDocArt(void);
- // Overrides
- override void DoContent(EventRecord* pEvent);
- virtual void DoIdle(void);
- override void Draw(void);
- // New functions
- virtual Boolean GetLocation(Ptr pName, Rect* theRect);
- virtual OSErr Init(short resID);
- virtual void Reset(void);
- virtual void LoadArt(void);
- virtual void SetCollisionEvent(AGEvent theEvent) {this->fCollisionEvent = theEvent;}
- virtual void SetWantCollision(Boolean doWant) {this->fWantCollision=doWant;}
- virtual void SetWantShuffle(Boolean doWant=true) {this->fWantShuffle=doWant;}
- virtual void SetWantReset(Boolean doWant=true) {this->fWantReset=doWant;}
- virtual void Shuffle(void);
- virtual Boolean WantCollision(void) {return this->fWantCollision;}
- };
-
-
- // ------------------------------------------------------------------------
- // A class for display of feedback.
- // Manages everything inside the window.
- class TDocFB : public TDoc
- {
- private:
- enum { // Content locations
- kLocH = 10,
- kLocCCV = 14,
- kLocCHV = 26,
- kLocEVV = 38,
- kLocMSV = 50,
- kLocCTV = 56
- };
- Point fLoc[4];
- ControlHandle fhControl;
- protected:
- public:
- // Constructor and destructor
- TDocFB(short resID);
- virtual ~TDocFB(void);
- // Overrides
- override void DoContent(EventRecord* pEvent);
- override void Draw(void);
- // New functions
- virtual void DrawData(Str255 string, short mode, short whichData);
- virtual OSErr Init(void);
- };
-
- // Global indexes for feedback items in the TDocFB window.
-
- enum {
- dataCC,
- dataCH,
- dataEV,
- dataTP
- };
-
- #endif __UDOCMO__